package com.qiangesoft.im.controller;

import com.qiangesoft.im.pojo.vo.ImChatVO;
import com.qiangesoft.im.pojo.vo.ResultInfo;
import com.qiangesoft.im.service.IImChatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 群组 前端控制器
 * </p>
 *
 * @author qiangesoft
 * @date 2024-02-07
 */
@Api(tags = "聊天")
@RequiredArgsConstructor
@RestController
@RequestMapping("/im/chat")
public class ImChatController {

    private final IImChatService chatService;

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除聊天")
    public ResultInfo<Void> removeChat(@PathVariable Long id) {
        chatService.removeChat(id);
        return ResultInfo.ok();
    }

    @GetMapping
    @ApiOperation(value = "聊天列表")
    public ResultInfo<List<ImChatVO>> listChat() {
        return ResultInfo.ok(chatService.listChat());
    }

    @PutMapping("/setTop/{id}")
    @ApiOperation(value = "置顶聊天")
    public ResultInfo<Void> setTop(@PathVariable Long id) {
        chatService.setTop(id);
        return ResultInfo.ok();
    }

    @PutMapping("/cancelTop/{id}")
    @ApiOperation(value = "取消置顶聊天")
    public ResultInfo<Void> cancelTop(@PathVariable Long id) {
        chatService.cancelTop(id);
        return ResultInfo.ok();
    }

}

